/*
 * Copyright 2007 Jeffrey Palm
 */

import java.io.*;
import java.util.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.*;

public class ItemForm extends Form {

  private final Item item;

  ItemForm(final Bloglines midlet, final Displayable prev, final Item item) {
    super(item.getTitle());
    this.item = item;
    final Command view = new Command("View",Command.OK,1);
    final Command back = new Command("Back",Command.BACK,1);
    addCommand(view);
    addCommand(back);
    setCommandListener(new CommandListener() {
	public void commandAction(Command c, Displayable d) {
	  if (c == view) {
	    try {
	      midlet.platformRequest(item.getLink());
	    } catch (Exception e) {
	      String msg = e.getMessage();
	      if (msg != null) msg = "Error";
	      Alert a = new Alert("Error",msg,null,AlertType.ERROR);
	      Display.getDisplay(midlet).setCurrent(a,ItemForm.this);
	    }
	  } else if (c == back) {
	    midlet.setCurrent(prev);
	  }
	}
      });
    StringItem text = new StringItem("",item.getDescription(),StringItem.PLAIN);
    append(text);
  }


}
